package treenode.visitor;



public class ParserTest{
  public static void main(String[] args)  {
    Parser parser = new Parser("( 1 + ( 10 - 8 % 2 ) * 5 ) % 8"); // spaces are vital!!;
    TreeNode rootNode = parser.parse();

    PreFixPrintVisitor preFixPrintVisitor = new PreFixPrintVisitor();
    System.out.print("PRE-ORDER: ");
    preFixPrintVisitor.visitBinaryOperatorNode((BinaryOperatorNode)rootNode);
    System.out.println();
    
    InFixPrintVisitor inFixPrintVisitor = new InFixPrintVisitor();
    System.out.print("IN-ORDER: ");
    inFixPrintVisitor.visitBinaryOperatorNode((BinaryOperatorNode)rootNode);
    System.out.println();
    
    PostFixPrintVisitor postFixPrintVisitor = new PostFixPrintVisitor();
    System.out.print("POST-ORDER: ");
    postFixPrintVisitor.visitBinaryOperatorNode((BinaryOperatorNode)rootNode);
    System.out.println();
    
    EvaluateVisitor evaluateVisitor = new EvaluateVisitor();
    System.out.print("RESULT: ");
    evaluateVisitor.visitBinaryOperatorNode((BinaryOperatorNode)rootNode);
    System.out.print(evaluateVisitor.getValue().toString());
    System.out.println();
    
    //System.out.println(rootNode.compute());
  }
}